package com.easy;

import java.util.ArrayList;
import java.util.List;
/**
 * Created by Lxk on 2019/7/13.
 */
public class Solution119 {

    public List<Integer> getRow(int rowIndex) {
        List<Integer> res = new ArrayList<>(rowIndex+1);
        if(rowIndex<=0){
            return res;
        }
        for(int i = 0;i <= rowIndex; i++){
            res.add(0);
        }
        for(int i = 0;i <= rowIndex; i++){
            for(int k = i;k >= 0; k--){
                if(k==0 || k==i){
                    res.set(k,1);
                }else{
                    int val = res.get(k)+res.get(k-1);
                    res.set(k,val);
                }
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Solution119 solution119 = new Solution119();
        System.out.println(solution119.getRow(3));
    }

}
